package com.meida.module.bus.provider.handler;

import com.meida.common.base.entity.EntityMap;
import com.meida.common.base.utils.FlymeUtils;
import com.meida.common.mybatis.interceptor.SaveInterceptor;
import com.meida.common.mybatis.query.CriteriaSave;
import com.meida.common.security.OpenHelper;
import com.meida.module.admin.client.entity.BaseUser;
import com.meida.module.bus.client.entity.BusSubject;
import org.springframework.stereotype.Component;

/**
 * 后台题目分类知识点添加逻辑
 *
 * @author zyf
 */
@Component
public class BusSubjectSaveHandler implements SaveInterceptor<BusSubject> {


    @Override
    public void prepare(CriteriaSave criteriaSave, EntityMap entityMap, BusSubject busSubject) {
        Long parentId = busSubject.getParentId();
        if (FlymeUtils.isEmpty(parentId)) {
            busSubject.setParentId(0L);
        }
        busSubject.setUserType(BaseUser.class.getSimpleName());
        busSubject.setUserId(OpenHelper.getUserId());
    }
}
